package com.example.swimmingpool.controller.order;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.swimmingpool.qo.order.OrderQo;
import com.example.swimmingpool.response.CommonResponse;
import com.example.swimmingpool.service.order.OrderService;
import com.example.swimmingpool.vo.order.OrderInfoVo;
import com.example.swimmingpool.vo.order.OrderVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @PostMapping("/buy")
    public CommonResponse<Boolean> buy(@RequestBody OrderVo vo) {
        return CommonResponse.success(orderService.buy(vo));
    }

    @PostMapping("/list")
    public CommonResponse<IPage<OrderInfoVo>> list(@RequestBody OrderQo qo) {
        return CommonResponse.success(orderService.list(qo));
    }

    @PostMapping("/listMy")
    public CommonResponse<List<OrderInfoVo>> list() {
        return CommonResponse.success(orderService.listMy());
    }
}
